//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;
using OpenLS.Drawing.Internals;

namespace OpenLS.Drawing
{
    internal class TableColumn : IOfficeXmlSerializable
    {
        internal const string xmlName = "gridCol";
        private OfficeArtExtensionList extLst;
        private double w;

        #region IOfficeXmlSerializable Members

        /// <summary>
        /// Generates an object from its XML representation
        /// </summary>
        /// <param name="context"></param>
        public void ReadXml(ReadContext context)
        {
            using (ReadContext c = context.Read(xmlName))
            {
                w = EmuConverter.FromEmu(c.GetInteger("w"));
                extLst = c.ReadOptionalElement<OfficeArtExtensionList>("extLst")
                    ;
            }
        }

        /// <summary>
        /// Convert an object into its XML representation
        /// </summary>
        /// <param name="context"></param>
        public void WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write(xmlName))
            {
                c.SetInteger64("w", EmuConverter.ToEmu(w));
                c.WriteOptionalElement(extLst);
            }
        }

        #endregion
    }
}